package cn.engage.feign;

import cn.engage.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component // 一定要交给spring管理
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {

  @Override
  public UserFeignClient create(Throwable throwable) {
    return new UserFeignClient() {
      @Override
      public User getUserById(Long id) {
        return new User(-1l,"熔断了", "触发熔断!");
      }
    };
  }
}
